const lodash = require('lodash');
const eachDeep = require('deepdash/getEachDeep')(lodash);
const treeData = require('./treeData');

const deepOptions = {
  childrenPath: 'children',
};
const levelPropName = 'levels';
eachDeep(
  treeData,
  (item, key, parent, context) => {
    item[levelPropName] = context.parents
      .map((item) => item.value.name)
      .concat(item.name);
    // console.log(`${item.name}的levels: `, item[levelPropName].join('/'));
  },
  deepOptions
);

console.log('original treedata: ', treeData);
console.log('treedata with levels: ', treeData);

console.log('treedata with levels: ', JSON.stringify(treeData, null, 2));
